package com.ticket.sass.admin.controller;


import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.ticket.sass.admin.annotation.Loggable;
import com.ticket.sass.admin.annotation.Module;
import com.ticket.sass.admin.business.impl.HallBusinessImpl;
import com.ticket.sass.admin.dto.input.hall.HallListInput;
import com.ticket.sass.admin.dto.input.hall.HallUpdInput;
import com.ticket.sass.admin.dto.output.hall.HallListOutput;
import com.ticket.sass.admin.model.PageModel;
import com.ticket.sass.admin.model.ResultModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ywb
 * @since 2024-03-07
 */
@RestController
@AllArgsConstructor
@ApiSupport(order = 5)
@Api(tags = {"影厅数据-模块"})
@RequestMapping("/halls")
public class HallController {
    final HallBusinessImpl hallBusiness;
    
    @GetMapping
    @ApiOperation("列表")
    public ResultModel<PageModel<HallListOutput>> list(
        @Valid HallListInput input
    ) {
        return ResultModel.success(
            hallBusiness.list(input)
        );
    }
    
    @PostMapping("/sync")
    @ApiOperation("同步")
    @Loggable(module = Module.HALL, desc = "同步")
    public ResultModel<String> sync() {
        hallBusiness.sync();
        return ResultModel.success();
    }
    
    @Loggable(module = Module.HALL, desc = "修改")
    @PutMapping
    @ApiOperation("修改")
    public ResultModel<String> upd(
        @RequestBody @Valid HallUpdInput input
    ) {
        hallBusiness.upd(input);
        return ResultModel.success();
    }
}
